<template>
  <el-container class="pageWrapper">
    <el-aside width="100px">
      <div class="label" @click="aaa">头条</div>
      <div class="avris">
        <div class="title">文章管理</div>
        <el-menu
          :default-active="$route.path"
          class="el-menu-vertical-demo"
          background-color="#545c64"
          text-color="#fff"
          active-text-color="#ffd04b"
        >
          <el-menu-item
            index="/ArticleList"
            class="fzchange"
            @click="jumpPage('/ArticleList')"
          >
            <i class="el-icon-menu"></i>
            <span slot="title">文章列表</span>
          </el-menu-item>

          <el-menu-item
            index="/PublishArticle"
            class="fzchange"
            @click="jumpPage('/PublishArticle')"
          >
            <i class="el-icon-setting"></i>
            <span slot="title">发布文章</span>
          </el-menu-item>
        </el-menu>
      </div>
    </el-aside>
    <el-container>
      <el-header height="100px">
        <div class="headInfo">
          <img
            :src="$axios.defaults.baseURL + user.head_img"
            alt
          
          
          />
          <div class="nickname">{{ user.nickname }}</div>
          <div class="logOut" @click="logOut">
            <a href="#">退出</a>
          </div>
        </div>
      </el-header>
      <el-main>
        <!-- 嵌套子路由,加入 router-view 标签 -->
        <Breadcrumb />
        <!-- <vueCropper
          ref="cropper"
          :img="option.img"
          :outputSize="option.size"
          :outputType="option.outputType"
        ></vueCropper> -->
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
import Breadcrumb from "../components/Breadcrumb";
// import uploadCropper from "../views/uploadCropper";
// import { VueCropper } from "vue-cropper";

export default {
  components: {
    Breadcrumb,
    // uploadCropper,
    // VueCropper
  },
  data() {
    return {
      user: {},
      isshow: false,
      // path: this.$route.path
      option: {
          img: 'https://avatars2.githubusercontent.com/u/15681693?s=460&v=4',
          size: 1,
          full: false,
          outputType: 'png',
          canMove: true,
          fixedBox: false,
          original: false,
          canMoveBox: true,
          autoCrop: true,
          // 只有自动截图开启 宽度高度才生效
          autoCropWidth: 160,
          autoCropHeight: 150,
          centerBox: false,
          high: true,
          max: 99999
        },
    };
  },
  methods: {
    logOut() {
      localStorage.removeItem("token");
      localStorage.removeItem("user");
      this.$router.replace("/login");
    },
    jumpPage(path) {
      if (this.$route.path != path) {
        this.$router.push(path);
      }
    },
    aaa(){
     this.$router.push("/bwa");
    }
  },

  mounted() {
    this.user = JSON.parse(localStorage.getItem("user"));
    console.log(this.user);
  }
};
</script>
<style lang="less" scoped>
.pageWrapper {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 100%;
}

.el-header,
.el-footer {
  background-color: #555;
  color: #333;
  line-height: 100px;
}

.el-aside {
  background-color: #222;
  color: rgb(255, 255, 255);
  text-align: center;
  line-height: 200px;
  .label {
    line-height: 100px;
    text-align: center;
    font-size: 30px;
    color: rgba(255, 255, 255, 0.87);
  }
  .title {
    margin-top: 40px;
    line-height: 80px;
    font-size: 22px;
  }
  .fzchange {
    font-size: 20px;
  }
}

// .el-main {
//   background-color: #f2f2f2;
//   color: #333;
//   text-align: center;
//   line-height: 60px;
// }

body > .el-container {
  margin-bottom: 40px;
}

.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
  line-height: 260px;
}

.el-container:nth-child(7) .el-aside {
  line-height: 320px;
}
.headInfo {
  display: flex;
  line-height: 100px;
  align-items: center;
  justify-content: flex-end;
  font-size: 22px;
  color: rgba(255, 255, 255, 0.788);
  img {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
  }
  .nickname {
    margin: 0 10px 0 15px;
  }
  .logOut {
    margin-right: 20px;
    a {
      text-decoration: none;
    }
  }
}
</style>
